<template>
  <div className="app-container">
    <div className="table-container">
      <base-list
        ref="table"
        url="/feeling_favorite"
        :options="options"
        :columns="columns"
        :format="format"
        :rules="rules"
        permission="ADMIN"
        @reloadOptions="handleGetOptions"
      />
    </div>
  </div>
</template>

<script>
import {getBaseList, getBaseOptions} from '@/api/common'
import BaseList from '@/components/BaseList/index.vue'

export default {
  name: 'FeelingFavorite',
  components: {BaseList},
  data() {
    return {
      columns: [
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'userId', label: '用户ID', tooltip: '用户ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingId', label: '碎片ID', tooltip: '碎片ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.bookId', label: '图书ID', tooltip: '图书ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.book', label: '图书', tooltip: '图书', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.bookSectionId', label: '图书章节ID', tooltip: '图书章节ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.bookSection', label: '图书章节', tooltip: '图书章节', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.content', label: '内容', tooltip: '内容', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.replyUserId', label: '被评论人ID', tooltip: '被评论人ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.replyUser', label: '被评论人', tooltip: '被评论人', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.userId', label: '评论人ID', tooltip: '评论人ID', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.user', label: '评论人', tooltip: '评论人', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.sign', label: '层级', tooltip: '层级', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.parentId', label: '上级id', tooltip: '上级id', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.level', label: '评论等级', tooltip: '评论等级', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.replyNum', label: '回复数量', tooltip: '回复数量', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.likeNum', label: '点赞数量', tooltip: '点赞数量', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.favoriteNum', label: '收藏数量', tooltip: '收藏数量', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.like', label: '是否喜欢', tooltip: '是否喜欢', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo.favorite', label: '是否收藏', tooltip: '是否收藏', type: 'WORD'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'feelingInfo', label: '碎片信息', tooltip: '碎片信息', type: 'WORD'},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'createTime', label: '创建时间', tooltip: '创建时间', type: 'DATE_TIME'},
        {show: true, edit: false, width: 'auto',minWidth: '200', key: 'updateTime', label: '更新时间', tooltip: '更新时间', type: 'DATE_TIME', queryable: true},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'createUser', label: '创建人', tooltip: '创建人', type: 'WORD'},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'updateUser', label: '修改人', tooltip: '修改人', type: 'WORD'},
      ],
      format: {
        createUser: (data, index) => {
          return data.createUser ? data.createUser.nickName + '('+data.createUser.id+')' : ''
        },
        updateUser: (data, index) => {
          return data.updateUser ? data.updateUser.nickName + '('+data.updateUser.id+')' : ''
        }
      },
      rules: {
        add: {
          userId: [{required: true, message: '用户ID必填!', trigger: 'blur'}],
          feelingId: [{required: true, message: '碎片ID必填!', trigger: 'blur'}],
          feelingInfo: [{required: true, message: '碎片信息必填!', trigger: 'blur'}],

        },
        edit: {
          id: [{required: true, message: '请选择数据!', trigger: 'change'}],
          userId: [{required: true, message: '用户ID必填!', trigger: 'blur'}],
          feelingId: [{required: true, message: '碎片ID必填!', trigger: 'blur'}],
          feelingInfo: [{required: true, message: '碎片信息必填!', trigger: 'blur'}],

        }
      },
      options: {
      }
    }
  },

  created() {
    this.handleGetOptions()
  },
  mounted() {
  },
  methods: {
    handleGetOptions() {
      const options = JSON.parse(localStorage.getItem('allOptions'))
      if (options) {
        this.options = Object.assign(this.options, options)
      }
    }
  }
}
</script>


